我是 BDD 新手,并尝试使用它来充实新项目的功能规范。
您在网上看到的大多数示例在细节方面似乎都非常简单且轻松。我很难知道场景中应该包含哪些内容以及不应该包含哪些内容。
例如,给定如下标题:用户登录
场景 1:用户使用有效凭据登录
鉴于显示登录页面
当用户输入用户名和密码时
并且用户提交请求
然后用户将被定向到主页
我不明白的是,如果用户被管理员禁用或由于密码尝试失败次数过多而被锁定,该怎么办?这些是单独的情况吗?如果是,场景 1是否需要表明该用户未被禁用且未被锁定?
后端发生的事情怎么样——即客户端希望系统记录每个用户的登录——这是否包含在场景中?我读过的大多数内容听起来好像 BDD 应该专注于用户与系统的交互。
如果您确实包含诸如登录后端之类的内容,那么在登录尝试失败时增加失败登录计数器之类的内容又如何呢?这看起来更像是一个技术细节——那么如果需要锁定功能,它在哪里记录呢?
正如您所看到的,我很难决定在 BDD 场景的范围方面划清界限。
感谢您帮助更好地理解!
当尝试将记录转换为 sql 中的 xml 时,我收到以下错误消息:
消息 6841,级别 16,状态 1,过程 trg_missacct_upd_del,第 58 行
FOR XML 无法序列化节点“AltAddr”的数据,因为它包含 XML 中不允许的字符 (0x0002)。要使用 FOR XML 检索此数据,请将其转换为二进制、varbinary 或图像数据类型并使用 BINARY BASE64 指令。
我想编写一个查询来查找哪个记录具有此十六进制值(0x0002)。我尝试过这样的事情:
select * from missacct where altaddr like '%' + 0x0002 + '%'
Run Code Online (Sandbox Code Playgroud)
有没有办法查询出这条记录?
我正在尝试使用 Passport-azure-ad 来验证用户身份。该应用程序显示常见的登录屏幕,但当我点击“登录”时,浏览器窗口变为空白并显示一个指示其工作的微调器。与此同时,我的服务器正在接收发送到我的回调端点的连续 POST 请求流。
在此期间,我的护照功能(验证、序列化用户和反序列化用户)都没有被调用。
这是我的策略定义:
passport.use("azure", new azureStrategy({
identityMetadata: 'https://login.microsoftonline.com/common/.well-known/openid-configuration',
clientID: "*************************",
responseType: 'code id_token',
issuer: "https://sts.windows.net/********************/",
responseMode: 'form_post',
redirectUrl: "http://localhost:5055/auth/azure/callback",
allowHttpForRedirectUrl: true,
clientSecret: "**********************************"
}, function(iss, sub, profile, accessToken, refreshToken, done) {
console.log("ID TOken: ", profile.oid); //Never gets called
console.log("User" ,profile) //Never gets called
done(null, profile);
}));
passport.serializeUser(function(user, done){
console.log("serialize: ", user) //Never gets called
done(null, user);
})
passport.deserializeUser((user, done) => {
console.log("deserialize: ", user) //never gets called
done(null, user);
})
Run Code Online (Sandbox Code Playgroud)
这是我的路线定义:
app.get("/auth/azure", passport.authenticate('azure', {failureRedirect: '/'}))
app.post("/auth/azure/callback", …Run Code Online (Sandbox Code Playgroud) 我正在使用 .NetCore 和 Cookie 身份验证。帐户管理(登录、注销等)全部通过 API 进行管理,而不是使用身份 UI。我的理解是服务器实际上无法向客户端发送任何内容来实际删除 cookie,相反,我需要“过期”服务器上的 cookie 并将其返回给客户端。
所以这是我的设置
启动文件
services.AddAuthentication("mycookie")
.AddCookie("mycookie", options => {
options.Cookie.HttpOnly = true;
options.SlidingExpiration = true;
options.ExpireTimeSpan = TimeSpan.FromMinutes(30);
options.Cookie.Expiration = TimeSpan.FromMinutes(30);
});
Run Code Online (Sandbox Code Playgroud)
在我的ApiController我有以下内容:
账户控制器.cs
[HttpGet("signout")]
public async Task<IActionResult> SignOut()
{
var temp = new AuthenticationProperties()
{
ExpiresUtc = DateTime.Now.AddDays(-1)
}
await HttpContext.SignOutAsync("mycookie",temp);
return Ok();
}
Run Code Online (Sandbox Code Playgroud)
但是,当我调用 .cookie 时,我的 cookie 似乎永远不会过期signout。我在浏览器开发控制台中注意到,cookie 显示Expires on: Session. 我本来希望在那里看到日期/时间。
如何在调用注销时摆脱 cookie 或使其过期?
我刚开始用KnockoutJS弄湿我的脚.到目前为止,我有以下内容:
HTML:
<b>Selected:</b> <span data-bind="text: selectedName" ></span>
<div data-bind="foreach: matches">
<div data-bind="click: $root.SelectMatch" >
<strong data-bind="text: Name" ></strong>
<span data-bind="text: Age"></span>
<span data-bind="text: Citizenship"></span>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
function TestViewModel() {
var self = this;
self.matches = ko.observableArray([
{ Name: 'Rodd Chin', Age: '42', Citizenship: 'American' },
{ Name: 'Ben Challinor', Age: '30', Citizenship: 'Russian'},
{ Name: 'Andrew Harris', Age: '35', Citizenship: 'Canadian' }
]);
self.selectedItem = ko.observable();
self.selectedName = ko.observable("[Empty]");
self.SelectMatch = function (match) {
self.selectedItem = match;
self.selectedName = …Run Code Online (Sandbox Code Playgroud) 我的控制器上有一个名为GetPhotos的动作.当我用适当的参数调用动作作为GET时,动作被调用,一切都很好.(我正在使用属性路由)
GET代码
[Route("getphotos")]
public IHttpActionResult GetPhotos(string userid, string password, string system, string outstation, string systemno, string version, string compid, string photono)
{
//Do some logic here
return OK();
}
Run Code Online (Sandbox Code Playgroud)
GET电话
GET http://localhost:60672/getphotos?userid=User1++&password=12345&system=UserSystem&outstation=9&systemno=3&version=6.78&compid=mycomputername&photono=003573
HTTP/1.1
User-Agent: Fiddler
Host: localhost:60672
Content-Type: application/x-www-form-urlencoded
Content-Length: 0
Run Code Online (Sandbox Code Playgroud)
但是,当我将操作更改为HttpPost并将我的调用更改为POST调用(通过Fiddler)时,我会返回404.
POST代码
[HttpPost]
[Route("getphotos")]
public IHttpActionResult GetPhotos(string userid, string password, string system, string outstation, string systemno, string version, string compid, string photono)
{
//Do some logic here
return OK();
}
Run Code Online (Sandbox Code Playgroud)
POST电话
POST http://localhost:60672/getphotos HTTP/1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: Fiddler
Host: …Run Code Online (Sandbox Code Playgroud) BundleConfig.cs
bundles.Add(new StyleBundle("~/Content/styles").Include(
"~/Content/css/test.css"
)
);
Run Code Online (Sandbox Code Playgroud)
_布局.cshtml
@Scripts.Render("~/Content/styles")
Run Code Online (Sandbox Code Playgroud)
测试.css
body{
font-size: 75%;
color: #232323;
text-align: left;
margin: 0px;
padding: 0px;}
Run Code Online (Sandbox Code Playgroud)
这就是 Chrome 显示为正在加载的内容,给我一个关于意外令牌 { 的语法错误:
body{font-size:75%;color:#232323;text-align:left;margin:0;padding:0}
Run Code Online (Sandbox Code Playgroud) adal ×1
asp.net-core ×1
bdd ×1
c# ×1
cookies ×1
knockout.js ×1
node.js ×1
passport.js ×1
routing ×1
sql-server ×1